


import requests
from xtquant import xtdata
from stock import Stock
from utils.stock import get_stock_list

class TickManager:
    stock_dict={}
    monitoring_dict={}
    def __init__(self):
        monitoring_request=requests.get('http://www.qmt.zj.cn:4000/api/monitoring/all')
        monitoring_json=monitoring_request.json()
        if monitoring_json['code']==200:
            for monitor in monitoring_json['data']:
                code=f'{monitor["code"]}.{monitor["market"]}'.upper()
                self.monitoring_dict[code]= monitor['recognitionStrategies']
        
        self.monitoring_dict["002467.SZ"]=["QUICKLYPULLUP"]
        stock_list=get_stock_list()
        for code in stock_list:
            self.stock_dict[code]=Stock(code,self.monitoring_dict[code] if code in self.monitoring_dict and isinstance(self.monitoring_dict[code], list) else [])

    def trigger(self,tick):
        for code in tick:
            if code in self.stock_dict:
                self.stock_dict[code].trigger(tick[code])




		
